import { FiledChildProps } from "@/types";
import { Input, Space } from "antd";
import { FormRowCol } from "@/components/common/FormRowCol.tsx";

export const WebSocket = ({
  storeData,
  onStoreDataChange,
}: FiledChildProps) => {
  return (
    <div style={{ padding: "10px" }}>
      <Space direction="vertical">
        <FormRowCol label="URL地址" illustrate={"必须以ws开头,否则不保存"}>
          <Input
            placeholder=""
            value={storeData.websocket}
            onChange={(e) => {
              onStoreDataChange("websocket", e.target.value);
              window.meta2d.connectSocket();
            }}
          />
        </FormRowCol>
        <FormRowCol label="protocols">
          <Input
            value={storeData.websocketProtocols}
            onChange={(e) => {
              onStoreDataChange("websocketProtocols", e.target.value);
            }}
          />
        </FormRowCol>
      </Space>
    </div>
  );
};
